

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>pyamp.ui.input.evdev &mdash; pyamp v1.2 documentation</title>
    <link rel="stylesheet" href="../../../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../../../',
        VERSION:     '1.2',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../../../_static/doctools.js"></script>
    <link rel="top" title="pyamp v1.2 documentation" href="../../../../index.html" />
    <link rel="up" title="pyamp.ui.input" href="../input.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../../../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="../../../index.html" >Module code</a> &raquo;</li>
          <li><a href="../input.html" accesskey="U">pyamp.ui.input</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <h1>Source code for pyamp.ui.input.evdev</h1><div class="highlight"><pre>
<span class="c">#!/usr/bin/env python</span>
<span class="c"># Copyright 2012 Brett Ponsler</span>
<span class="c"># This file is part of pyamp.</span>
<span class="c">#</span>
<span class="c"># pyamp is free software: you can redistribute it and/or modify</span>
<span class="c"># it under the terms of the GNU General Public License as published by</span>
<span class="c"># the Free Software Foundation, either version 3 of the License, or</span>
<span class="c"># (at your option) any later version.</span>
<span class="c">#</span>
<span class="c"># pyamp is distributed in the hope that it will be useful,</span>
<span class="c"># but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="c"># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span class="c"># GNU General Public License for more details.</span>
<span class="c">#</span>
<span class="c"># You should have received a copy of the GNU General Public License</span>
<span class="c"># along with pyamp.  If not, see &lt;http://www.gnu.org/licenses/&gt;.</span>
<span class="sd">&quot;&quot;&quot; evdev.py</span>

<span class="sd">This is a Python interface to the Linux input system&#39;s event device.</span>
<span class="sd">Events can be read from an open event file and decoded into spiffy</span>
<span class="sd">python objects. The Event objects can optionally be fed into a Device</span>
<span class="sd">object that represents the complete state of the device being monitored.</span>

<span class="sd">Copyright (C) 2003-2004 Micah Dowty &lt;micah@navi.cx&gt;</span>

<span class="sd">This program is free software; you can redistribute it and/or modify</span>
<span class="sd">it under the terms of the GNU General Public License as published by</span>
<span class="sd">the Free Software Foundation; either version 2 of the License, or</span>
<span class="sd">(at your option) any later version.</span>

<span class="sd">This program is distributed in the hope that it will be useful,</span>
<span class="sd">but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="sd">MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span class="sd">GNU General Public License for more details.</span>

<span class="sd">You should have received a copy of the GNU General Public License</span>
<span class="sd">along with this program; if not, write to the Free Software</span>
<span class="sd">Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">struct</span><span class="o">,</span> <span class="nn">sys</span><span class="o">,</span> <span class="nn">os</span><span class="o">,</span> <span class="nn">time</span>
<span class="kn">from</span> <span class="nn">fcntl</span> <span class="kn">import</span> <span class="n">ioctl</span>

<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span><span class="s">&quot;Event&quot;</span><span class="p">,</span> <span class="s">&quot;Device&quot;</span><span class="p">]</span>

<span class="k">def</span> <span class="nf">demo</span><span class="p">():</span>
    <span class="sd">&quot;&quot;&quot;Open the event device named on the command line, use incoming</span>
<span class="sd">       events to update a device, and show the state of this device.</span>
<span class="sd">       &quot;&quot;&quot;</span>
    <span class="n">dev</span> <span class="o">=</span> <span class="n">Device</span><span class="p">(</span><span class="n">sys</span><span class="o">.</span><span class="n">argv</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
    <span class="k">while</span> <span class="mi">1</span><span class="p">:</span>
        <span class="n">dev</span><span class="o">.</span><span class="n">poll</span><span class="p">()</span>
        <span class="n">time</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mf">0.01</span><span class="p">)</span>
        <span class="k">print</span> <span class="n">dev</span>


<div class="viewcode-block" id="BaseDevice"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_input_evdev.html#pyamp.ui.input.evdev.BaseDevice">[docs]</a><span class="k">class</span> <span class="nc">BaseDevice</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;Base class representing the state of an input device, with axes and buttons.</span>
<span class="sd">       Event instances can be fed into the Device to update its state.</span>
<span class="sd">       &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">axes</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">buttons</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="bp">None</span>

    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s">&quot;&lt;Device name=</span><span class="si">%r</span><span class="s"> axes=</span><span class="si">%r</span><span class="s"> buttons=</span><span class="si">%r</span><span class="s">&gt;&quot;</span> <span class="o">%</span> <span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">axes</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">buttons</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">update</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
        <span class="n">f</span> <span class="o">=</span> <span class="nb">getattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s">&quot;update_</span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">event</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">f</span><span class="p">(</span><span class="n">event</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">update_EV_KEY</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">buttons</span><span class="p">[</span><span class="n">event</span><span class="o">.</span><span class="n">code</span><span class="p">]</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">value</span>

    <span class="k">def</span> <span class="nf">update_EV_ABS</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">axes</span><span class="p">[</span><span class="n">event</span><span class="o">.</span><span class="n">code</span><span class="p">]</span> <span class="o">=</span> <span class="n">event</span><span class="o">.</span><span class="n">value</span>

    <span class="k">def</span> <span class="nf">update_EV_REL</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">axes</span><span class="p">[</span><span class="n">event</span><span class="o">.</span><span class="n">code</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">axes</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">event</span><span class="o">.</span><span class="n">code</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span> <span class="o">+</span> <span class="n">event</span><span class="o">.</span><span class="n">value</span>

    <span class="k">def</span> <span class="nf">__getitem__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Retrieve the current value of an axis or button,</span>
<span class="sd">           or zero if no data has been received for it yet.</span>
<span class="sd">           &quot;&quot;&quot;</span>
        <span class="k">if</span> <span class="n">name</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">axes</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">axes</span><span class="p">[</span><span class="n">name</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">buttons</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>


<span class="c"># evdev ioctl constants. The horrible mess here</span>
<span class="c"># is to silence silly FutureWarnings</span></div>
<span class="n">EVIOCGNAME_512</span> <span class="o">=</span> <span class="o">~</span><span class="nb">int</span><span class="p">(</span><span class="o">~</span><span class="mh">0x82004506</span><span class="n">L</span> <span class="o">&amp;</span> <span class="mh">0xFFFFFFFF</span><span class="n">L</span><span class="p">)</span>
<span class="n">EVIOCGID</span>       <span class="o">=</span> <span class="o">~</span><span class="nb">int</span><span class="p">(</span><span class="o">~</span><span class="mh">0x80084502</span><span class="n">L</span> <span class="o">&amp;</span> <span class="mh">0xFFFFFFFF</span><span class="n">L</span><span class="p">)</span>
<span class="n">EVIOCGBIT_512</span>  <span class="o">=</span> <span class="o">~</span><span class="nb">int</span><span class="p">(</span><span class="o">~</span><span class="mh">0x81fe4520</span><span class="n">L</span> <span class="o">&amp;</span> <span class="mh">0xFFFFFFFF</span><span class="n">L</span><span class="p">)</span>
<span class="n">EVIOCGABS_512</span>  <span class="o">=</span> <span class="o">~</span><span class="nb">int</span><span class="p">(</span><span class="o">~</span><span class="mh">0x80144540</span><span class="n">L</span> <span class="o">&amp;</span> <span class="mh">0xFFFFFFFF</span><span class="n">L</span><span class="p">)</span>


<div class="viewcode-block" id="Device"><a class="viewcode-back" href="../../../../ui.html#pyamp.ui.input.evdev.Device">[docs]</a><span class="k">class</span> <span class="nc">Device</span><span class="p">(</span><span class="n">BaseDevice</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot;An abstract input device attached to a Linux evdev device node&quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">):</span>
        <span class="n">BaseDevice</span><span class="o">.</span><span class="n">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">fd</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">open</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">O_RDWR</span> <span class="o">|</span> <span class="n">os</span><span class="o">.</span><span class="n">O_NONBLOCK</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">packetSize</span> <span class="o">=</span> <span class="n">Event</span><span class="o">.</span><span class="n">get_format_size</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">readMetadata</span><span class="p">()</span>

<div class="viewcode-block" id="Device.poll"><a class="viewcode-back" href="../../../../ui.html#pyamp.ui.input.evdev.Device.poll">[docs]</a>    <span class="k">def</span> <span class="nf">poll</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Receive and process all available input events&quot;&quot;&quot;</span>
        <span class="k">while</span> <span class="mi">1</span><span class="p">:</span>
            <span class="k">try</span><span class="p">:</span>
                <span class="nb">buffer</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fd</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">packetSize</span><span class="p">)</span>
            <span class="k">except</span> <span class="ne">OSError</span><span class="p">:</span>
                <span class="k">return</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">Event</span><span class="p">(</span><span class="n">unpack</span><span class="o">=</span><span class="nb">buffer</span><span class="p">))</span>
</div>
<div class="viewcode-block" id="Device.readMetadata"><a class="viewcode-back" href="../../../../ui.html#pyamp.ui.input.evdev.Device.readMetadata">[docs]</a>    <span class="k">def</span> <span class="nf">readMetadata</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Read device identity and capabilities via ioctl()&quot;&quot;&quot;</span>
        <span class="nb">buffer</span> <span class="o">=</span> <span class="s">&quot;</span><span class="se">\0</span><span class="s">&quot;</span><span class="o">*</span><span class="mi">512</span>

        <span class="c"># Read the name</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="n">ioctl</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fd</span><span class="p">,</span> <span class="n">EVIOCGNAME_512</span><span class="p">,</span> <span class="nb">buffer</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">name</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="p">[:</span><span class="bp">self</span><span class="o">.</span><span class="n">name</span><span class="o">.</span><span class="n">find</span><span class="p">(</span><span class="s">&quot;</span><span class="se">\0</span><span class="s">&quot;</span><span class="p">)]</span>

        <span class="c"># Read info on each absolute axis</span>
        <span class="n">absmap</span> <span class="o">=</span> <span class="n">Event</span><span class="o">.</span><span class="n">codeMaps</span><span class="p">[</span><span class="s">&#39;EV_ABS&#39;</span><span class="p">]</span>
        <span class="nb">buffer</span> <span class="o">=</span> <span class="s">&quot;</span><span class="se">\0</span><span class="s">&quot;</span> <span class="o">*</span> <span class="n">struct</span><span class="o">.</span><span class="n">calcsize</span><span class="p">(</span><span class="s">&quot;iiiii&quot;</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">absAxisInfo</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">name</span><span class="p">,</span> <span class="n">number</span> <span class="ow">in</span> <span class="n">absmap</span><span class="o">.</span><span class="n">nameMap</span><span class="o">.</span><span class="n">iteritems</span><span class="p">():</span>
            <span class="n">values</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="s">&quot;iiiii&quot;</span><span class="p">,</span> <span class="n">ioctl</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fd</span><span class="p">,</span> <span class="n">EVIOCGABS_512</span> <span class="o">+</span> <span class="n">number</span><span class="p">,</span> <span class="nb">buffer</span><span class="p">))</span>
            <span class="n">values</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">(</span><span class="nb">zip</span><span class="p">((</span> <span class="s">&#39;value&#39;</span><span class="p">,</span> <span class="s">&#39;min&#39;</span><span class="p">,</span> <span class="s">&#39;max&#39;</span><span class="p">,</span> <span class="s">&#39;fuzz&#39;</span><span class="p">,</span> <span class="s">&#39;flat&#39;</span> <span class="p">),</span><span class="n">values</span><span class="p">))</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">absAxisInfo</span><span class="p">[</span><span class="n">name</span><span class="p">]</span> <span class="o">=</span> <span class="n">values</span>
</div>
<div class="viewcode-block" id="Device.update_EV_ABS"><a class="viewcode-back" href="../../../../ui.html#pyamp.ui.input.evdev.Device.update_EV_ABS">[docs]</a>    <span class="k">def</span> <span class="nf">update_EV_ABS</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">event</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Scale the absolute axis into the range [-1, 1] using absAxisInfo&quot;&quot;&quot;</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">info</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">absAxisInfo</span><span class="p">[</span><span class="n">event</span><span class="o">.</span><span class="n">code</span><span class="p">]</span>
        <span class="k">except</span> <span class="ne">KeyError</span><span class="p">:</span>
            <span class="k">return</span>
        <span class="nb">range</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">info</span><span class="p">[</span><span class="s">&#39;max&#39;</span><span class="p">]</span> <span class="o">-</span> <span class="n">info</span><span class="p">[</span><span class="s">&#39;min&#39;</span><span class="p">])</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">axes</span><span class="p">[</span><span class="n">event</span><span class="o">.</span><span class="n">code</span><span class="p">]</span> <span class="o">=</span> <span class="p">(</span><span class="n">event</span><span class="o">.</span><span class="n">value</span> <span class="o">-</span> <span class="n">info</span><span class="p">[</span><span class="s">&#39;min&#39;</span><span class="p">])</span> <span class="o">/</span> <span class="nb">range</span> <span class="o">*</span> <span class="mf">2.0</span> <span class="o">-</span> <span class="mf">1.0</span>

</div></div>
<div class="viewcode-block" id="EnumDict"><a class="viewcode-back" href="../../../../_generated/pyamp_ui_input_evdev.html#pyamp.ui.input.evdev.EnumDict">[docs]</a><span class="k">class</span> <span class="nc">EnumDict</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;A 1:1 mapping from numbers to strings or other objects, for enumerated</span>
<span class="sd">       types and other assigned numbers. The mapping can be queried in either</span>
<span class="sd">       direction. All values, by default, map to themselves.</span>
<span class="sd">       &quot;&quot;&quot;</span>
    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">numberMap</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">numberMap</span> <span class="o">=</span> <span class="n">numberMap</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">nameMap</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">numberMap</span><span class="o">.</span><span class="n">iteritems</span><span class="p">():</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">nameMap</span><span class="p">[</span><span class="n">value</span><span class="p">]</span> <span class="o">=</span> <span class="n">key</span>

    <span class="k">def</span> <span class="nf">toNumber</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">nameMap</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">name</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">fromNumber</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">num</span><span class="p">):</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">numberMap</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">num</span><span class="p">,</span> <span class="n">num</span><span class="p">)</span>

</div>
<div class="viewcode-block" id="Event"><a class="viewcode-back" href="../../../../ui.html#pyamp.ui.input.evdev.Event">[docs]</a><span class="k">class</span> <span class="nc">Event</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;Represents one linux input system event. It can</span>
<span class="sd">       be encoded and decoded in the &#39;struct input_event&#39;</span>
<span class="sd">       format used by the kernel. Types and codes are automatically</span>
<span class="sd">       encoded and decoded with the #define names used in input.h</span>
<span class="sd">       &quot;&quot;&quot;</span>
    <span class="n">ts_format</span> <span class="o">=</span> <span class="s">&quot;@LL&quot;</span>
    <span class="n">format</span> <span class="o">=</span> <span class="s">&quot;=HHl&quot;</span>

    <span class="n">typeMap</span> <span class="o">=</span> <span class="n">EnumDict</span><span class="p">({</span>
        <span class="mh">0x00</span><span class="p">:</span> <span class="s">&quot;EV_RST&quot;</span><span class="p">,</span>
        <span class="mh">0x01</span><span class="p">:</span> <span class="s">&quot;EV_KEY&quot;</span><span class="p">,</span>
        <span class="mh">0x02</span><span class="p">:</span> <span class="s">&quot;EV_REL&quot;</span><span class="p">,</span>
        <span class="mh">0x03</span><span class="p">:</span> <span class="s">&quot;EV_ABS&quot;</span><span class="p">,</span>
        <span class="mh">0x04</span><span class="p">:</span> <span class="s">&quot;EV_MSC&quot;</span><span class="p">,</span>
        <span class="mh">0x11</span><span class="p">:</span> <span class="s">&quot;EV_LED&quot;</span><span class="p">,</span>
        <span class="mh">0x12</span><span class="p">:</span> <span class="s">&quot;EV_SND&quot;</span><span class="p">,</span>
        <span class="mh">0x14</span><span class="p">:</span> <span class="s">&quot;EV_REP&quot;</span><span class="p">,</span>
        <span class="mh">0x15</span><span class="p">:</span> <span class="s">&quot;EV_FF&quot;</span><span class="p">,</span>
        <span class="p">})</span>

    <span class="n">codeMaps</span> <span class="o">=</span> <span class="p">{</span>

        <span class="s">&quot;EV_KEY&quot;</span><span class="p">:</span> <span class="n">EnumDict</span><span class="p">({</span>
        <span class="mi">0</span><span class="p">:</span> <span class="s">&quot;KEY_RESERVED&quot;</span><span class="p">,</span>
        <span class="mi">1</span><span class="p">:</span> <span class="s">&quot;KEY_ESC&quot;</span><span class="p">,</span>
        <span class="mi">2</span><span class="p">:</span> <span class="s">&quot;KEY_1&quot;</span><span class="p">,</span>
        <span class="mi">3</span><span class="p">:</span> <span class="s">&quot;KEY_2&quot;</span><span class="p">,</span>
        <span class="mi">4</span><span class="p">:</span> <span class="s">&quot;KEY_3&quot;</span><span class="p">,</span>
        <span class="mi">5</span><span class="p">:</span> <span class="s">&quot;KEY_4&quot;</span><span class="p">,</span>
        <span class="mi">6</span><span class="p">:</span> <span class="s">&quot;KEY_5&quot;</span><span class="p">,</span>
        <span class="mi">7</span><span class="p">:</span> <span class="s">&quot;KEY_6&quot;</span><span class="p">,</span>
        <span class="mi">8</span><span class="p">:</span> <span class="s">&quot;KEY_7&quot;</span><span class="p">,</span>
        <span class="mi">9</span><span class="p">:</span> <span class="s">&quot;KEY_8&quot;</span><span class="p">,</span>
        <span class="mi">10</span><span class="p">:</span> <span class="s">&quot;KEY_9&quot;</span><span class="p">,</span>
        <span class="mi">11</span><span class="p">:</span> <span class="s">&quot;KEY_0&quot;</span><span class="p">,</span>
        <span class="mi">12</span><span class="p">:</span> <span class="s">&quot;KEY_MINUS&quot;</span><span class="p">,</span>
        <span class="mi">13</span><span class="p">:</span> <span class="s">&quot;KEY_EQUAL&quot;</span><span class="p">,</span>
        <span class="mi">14</span><span class="p">:</span> <span class="s">&quot;KEY_BACKSPACE&quot;</span><span class="p">,</span>
        <span class="mi">15</span><span class="p">:</span> <span class="s">&quot;KEY_TAB&quot;</span><span class="p">,</span>
        <span class="mi">16</span><span class="p">:</span> <span class="s">&quot;KEY_Q&quot;</span><span class="p">,</span>
        <span class="mi">17</span><span class="p">:</span> <span class="s">&quot;KEY_W&quot;</span><span class="p">,</span>
        <span class="mi">18</span><span class="p">:</span> <span class="s">&quot;KEY_E&quot;</span><span class="p">,</span>
        <span class="mi">19</span><span class="p">:</span> <span class="s">&quot;KEY_R&quot;</span><span class="p">,</span>
        <span class="mi">20</span><span class="p">:</span> <span class="s">&quot;KEY_T&quot;</span><span class="p">,</span>
        <span class="mi">21</span><span class="p">:</span> <span class="s">&quot;KEY_Y&quot;</span><span class="p">,</span>
        <span class="mi">22</span><span class="p">:</span> <span class="s">&quot;KEY_U&quot;</span><span class="p">,</span>
        <span class="mi">23</span><span class="p">:</span> <span class="s">&quot;KEY_I&quot;</span><span class="p">,</span>
        <span class="mi">24</span><span class="p">:</span> <span class="s">&quot;KEY_O&quot;</span><span class="p">,</span>
        <span class="mi">25</span><span class="p">:</span> <span class="s">&quot;KEY_P&quot;</span><span class="p">,</span>
        <span class="mi">26</span><span class="p">:</span> <span class="s">&quot;KEY_LEFTBRACE&quot;</span><span class="p">,</span>
        <span class="mi">27</span><span class="p">:</span> <span class="s">&quot;KEY_RIGHTBRACE&quot;</span><span class="p">,</span>
        <span class="mi">28</span><span class="p">:</span> <span class="s">&quot;KEY_ENTER&quot;</span><span class="p">,</span>
        <span class="mi">29</span><span class="p">:</span> <span class="s">&quot;KEY_LEFTCTRL&quot;</span><span class="p">,</span>
        <span class="mi">30</span><span class="p">:</span> <span class="s">&quot;KEY_A&quot;</span><span class="p">,</span>
        <span class="mi">31</span><span class="p">:</span> <span class="s">&quot;KEY_S&quot;</span><span class="p">,</span>
        <span class="mi">32</span><span class="p">:</span> <span class="s">&quot;KEY_D&quot;</span><span class="p">,</span>
        <span class="mi">33</span><span class="p">:</span> <span class="s">&quot;KEY_F&quot;</span><span class="p">,</span>
        <span class="mi">34</span><span class="p">:</span> <span class="s">&quot;KEY_G&quot;</span><span class="p">,</span>
        <span class="mi">35</span><span class="p">:</span> <span class="s">&quot;KEY_H&quot;</span><span class="p">,</span>
        <span class="mi">36</span><span class="p">:</span> <span class="s">&quot;KEY_J&quot;</span><span class="p">,</span>
        <span class="mi">37</span><span class="p">:</span> <span class="s">&quot;KEY_K&quot;</span><span class="p">,</span>
        <span class="mi">38</span><span class="p">:</span> <span class="s">&quot;KEY_L&quot;</span><span class="p">,</span>
        <span class="mi">39</span><span class="p">:</span> <span class="s">&quot;KEY_SEMICOLON&quot;</span><span class="p">,</span>
        <span class="mi">40</span><span class="p">:</span> <span class="s">&quot;KEY_APOSTROPHE&quot;</span><span class="p">,</span>
        <span class="mi">41</span><span class="p">:</span> <span class="s">&quot;KEY_GRAVE&quot;</span><span class="p">,</span>
        <span class="mi">42</span><span class="p">:</span> <span class="s">&quot;KEY_LEFTSHIFT&quot;</span><span class="p">,</span>
        <span class="mi">43</span><span class="p">:</span> <span class="s">&quot;KEY_BACKSLASH&quot;</span><span class="p">,</span>
        <span class="mi">44</span><span class="p">:</span> <span class="s">&quot;KEY_Z&quot;</span><span class="p">,</span>
        <span class="mi">45</span><span class="p">:</span> <span class="s">&quot;KEY_X&quot;</span><span class="p">,</span>
        <span class="mi">46</span><span class="p">:</span> <span class="s">&quot;KEY_C&quot;</span><span class="p">,</span>
        <span class="mi">47</span><span class="p">:</span> <span class="s">&quot;KEY_V&quot;</span><span class="p">,</span>
        <span class="mi">48</span><span class="p">:</span> <span class="s">&quot;KEY_B&quot;</span><span class="p">,</span>
        <span class="mi">49</span><span class="p">:</span> <span class="s">&quot;KEY_N&quot;</span><span class="p">,</span>
        <span class="mi">50</span><span class="p">:</span> <span class="s">&quot;KEY_M&quot;</span><span class="p">,</span>
        <span class="mi">51</span><span class="p">:</span> <span class="s">&quot;KEY_COMMA&quot;</span><span class="p">,</span>
        <span class="mi">52</span><span class="p">:</span> <span class="s">&quot;KEY_DOT&quot;</span><span class="p">,</span>
        <span class="mi">53</span><span class="p">:</span> <span class="s">&quot;KEY_SLASH&quot;</span><span class="p">,</span>
        <span class="mi">54</span><span class="p">:</span> <span class="s">&quot;KEY_RIGHTSHIFT&quot;</span><span class="p">,</span>
        <span class="mi">55</span><span class="p">:</span> <span class="s">&quot;KEY_KPASTERISK&quot;</span><span class="p">,</span>
        <span class="mi">56</span><span class="p">:</span> <span class="s">&quot;KEY_LEFTALT&quot;</span><span class="p">,</span>
        <span class="mi">57</span><span class="p">:</span> <span class="s">&quot;KEY_SPACE&quot;</span><span class="p">,</span>
        <span class="mi">58</span><span class="p">:</span> <span class="s">&quot;KEY_CAPSLOCK&quot;</span><span class="p">,</span>
        <span class="mi">59</span><span class="p">:</span> <span class="s">&quot;KEY_F1&quot;</span><span class="p">,</span>
        <span class="mi">60</span><span class="p">:</span> <span class="s">&quot;KEY_F2&quot;</span><span class="p">,</span>
        <span class="mi">61</span><span class="p">:</span> <span class="s">&quot;KEY_F3&quot;</span><span class="p">,</span>
        <span class="mi">62</span><span class="p">:</span> <span class="s">&quot;KEY_F4&quot;</span><span class="p">,</span>
        <span class="mi">63</span><span class="p">:</span> <span class="s">&quot;KEY_F5&quot;</span><span class="p">,</span>
        <span class="mi">64</span><span class="p">:</span> <span class="s">&quot;KEY_F6&quot;</span><span class="p">,</span>
        <span class="mi">65</span><span class="p">:</span> <span class="s">&quot;KEY_F7&quot;</span><span class="p">,</span>
        <span class="mi">66</span><span class="p">:</span> <span class="s">&quot;KEY_F8&quot;</span><span class="p">,</span>
        <span class="mi">67</span><span class="p">:</span> <span class="s">&quot;KEY_F9&quot;</span><span class="p">,</span>
        <span class="mi">68</span><span class="p">:</span> <span class="s">&quot;KEY_F10&quot;</span><span class="p">,</span>
        <span class="mi">69</span><span class="p">:</span> <span class="s">&quot;KEY_NUMLOCK&quot;</span><span class="p">,</span>
        <span class="mi">70</span><span class="p">:</span> <span class="s">&quot;KEY_SCROLLLOCK&quot;</span><span class="p">,</span>
        <span class="mi">71</span><span class="p">:</span> <span class="s">&quot;KEY_KP7&quot;</span><span class="p">,</span>
        <span class="mi">72</span><span class="p">:</span> <span class="s">&quot;KEY_KP8&quot;</span><span class="p">,</span>
        <span class="mi">73</span><span class="p">:</span> <span class="s">&quot;KEY_KP9&quot;</span><span class="p">,</span>
        <span class="mi">74</span><span class="p">:</span> <span class="s">&quot;KEY_KPMINUS&quot;</span><span class="p">,</span>
        <span class="mi">75</span><span class="p">:</span> <span class="s">&quot;KEY_KP4&quot;</span><span class="p">,</span>
        <span class="mi">76</span><span class="p">:</span> <span class="s">&quot;KEY_KP5&quot;</span><span class="p">,</span>
        <span class="mi">77</span><span class="p">:</span> <span class="s">&quot;KEY_KP6&quot;</span><span class="p">,</span>
        <span class="mi">78</span><span class="p">:</span> <span class="s">&quot;KEY_KPPLUS&quot;</span><span class="p">,</span>
        <span class="mi">79</span><span class="p">:</span> <span class="s">&quot;KEY_KP1&quot;</span><span class="p">,</span>
        <span class="mi">80</span><span class="p">:</span> <span class="s">&quot;KEY_KP2&quot;</span><span class="p">,</span>
        <span class="mi">81</span><span class="p">:</span> <span class="s">&quot;KEY_KP3&quot;</span><span class="p">,</span>
        <span class="mi">82</span><span class="p">:</span> <span class="s">&quot;KEY_KP0&quot;</span><span class="p">,</span>
        <span class="mi">83</span><span class="p">:</span> <span class="s">&quot;KEY_KPDOT&quot;</span><span class="p">,</span>
        <span class="mi">84</span><span class="p">:</span> <span class="s">&quot;KEY_103RD&quot;</span><span class="p">,</span>
        <span class="mi">85</span><span class="p">:</span> <span class="s">&quot;KEY_F13&quot;</span><span class="p">,</span>
        <span class="mi">86</span><span class="p">:</span> <span class="s">&quot;KEY_102ND&quot;</span><span class="p">,</span>
        <span class="mi">87</span><span class="p">:</span> <span class="s">&quot;KEY_F11&quot;</span><span class="p">,</span>
        <span class="mi">88</span><span class="p">:</span> <span class="s">&quot;KEY_F12&quot;</span><span class="p">,</span>
        <span class="mi">89</span><span class="p">:</span> <span class="s">&quot;KEY_F14&quot;</span><span class="p">,</span>
        <span class="mi">90</span><span class="p">:</span> <span class="s">&quot;KEY_F15&quot;</span><span class="p">,</span>
        <span class="mi">91</span><span class="p">:</span> <span class="s">&quot;KEY_F16&quot;</span><span class="p">,</span>
        <span class="mi">92</span><span class="p">:</span> <span class="s">&quot;KEY_F17&quot;</span><span class="p">,</span>
        <span class="mi">93</span><span class="p">:</span> <span class="s">&quot;KEY_F18&quot;</span><span class="p">,</span>
        <span class="mi">94</span><span class="p">:</span> <span class="s">&quot;KEY_F19&quot;</span><span class="p">,</span>
        <span class="mi">95</span><span class="p">:</span> <span class="s">&quot;KEY_F20&quot;</span><span class="p">,</span>
        <span class="mi">96</span><span class="p">:</span> <span class="s">&quot;KEY_KPENTER&quot;</span><span class="p">,</span>
        <span class="mi">97</span><span class="p">:</span> <span class="s">&quot;KEY_RIGHTCTRL&quot;</span><span class="p">,</span>
        <span class="mi">98</span><span class="p">:</span> <span class="s">&quot;KEY_KPSLASH&quot;</span><span class="p">,</span>
        <span class="mi">99</span><span class="p">:</span> <span class="s">&quot;KEY_SYSRQ&quot;</span><span class="p">,</span>
        <span class="mi">100</span><span class="p">:</span> <span class="s">&quot;KEY_RIGHTALT&quot;</span><span class="p">,</span>
        <span class="mi">101</span><span class="p">:</span> <span class="s">&quot;KEY_LINEFEED&quot;</span><span class="p">,</span>
        <span class="mi">102</span><span class="p">:</span> <span class="s">&quot;KEY_HOME&quot;</span><span class="p">,</span>
        <span class="mi">103</span><span class="p">:</span> <span class="s">&quot;KEY_UP&quot;</span><span class="p">,</span>
        <span class="mi">104</span><span class="p">:</span> <span class="s">&quot;KEY_PAGEUP&quot;</span><span class="p">,</span>
        <span class="mi">105</span><span class="p">:</span> <span class="s">&quot;KEY_LEFT&quot;</span><span class="p">,</span>
        <span class="mi">106</span><span class="p">:</span> <span class="s">&quot;KEY_RIGHT&quot;</span><span class="p">,</span>
        <span class="mi">107</span><span class="p">:</span> <span class="s">&quot;KEY_END&quot;</span><span class="p">,</span>
        <span class="mi">108</span><span class="p">:</span> <span class="s">&quot;KEY_DOWN&quot;</span><span class="p">,</span>
        <span class="mi">109</span><span class="p">:</span> <span class="s">&quot;KEY_PAGEDOWN&quot;</span><span class="p">,</span>
        <span class="mi">110</span><span class="p">:</span> <span class="s">&quot;KEY_INSERT&quot;</span><span class="p">,</span>
        <span class="mi">111</span><span class="p">:</span> <span class="s">&quot;KEY_DELETE&quot;</span><span class="p">,</span>
        <span class="mi">112</span><span class="p">:</span> <span class="s">&quot;KEY_MACRO&quot;</span><span class="p">,</span>
        <span class="mi">113</span><span class="p">:</span> <span class="s">&quot;KEY_MUTE&quot;</span><span class="p">,</span>
        <span class="mi">114</span><span class="p">:</span> <span class="s">&quot;KEY_VOLUMEDOWN&quot;</span><span class="p">,</span>
        <span class="mi">115</span><span class="p">:</span> <span class="s">&quot;KEY_VOLUMEUP&quot;</span><span class="p">,</span>
        <span class="mi">116</span><span class="p">:</span> <span class="s">&quot;KEY_POWER&quot;</span><span class="p">,</span>
        <span class="mi">117</span><span class="p">:</span> <span class="s">&quot;KEY_KPEQUAL&quot;</span><span class="p">,</span>
        <span class="mi">118</span><span class="p">:</span> <span class="s">&quot;KEY_KPPLUSMINUS&quot;</span><span class="p">,</span>
        <span class="mi">119</span><span class="p">:</span> <span class="s">&quot;KEY_PAUSE&quot;</span><span class="p">,</span>
        <span class="mi">120</span><span class="p">:</span> <span class="s">&quot;KEY_F21&quot;</span><span class="p">,</span>
        <span class="mi">121</span><span class="p">:</span> <span class="s">&quot;KEY_F22&quot;</span><span class="p">,</span>
        <span class="mi">122</span><span class="p">:</span> <span class="s">&quot;KEY_F23&quot;</span><span class="p">,</span>
        <span class="mi">123</span><span class="p">:</span> <span class="s">&quot;KEY_F24&quot;</span><span class="p">,</span>
        <span class="mi">124</span><span class="p">:</span> <span class="s">&quot;KEY_KPCOMMA&quot;</span><span class="p">,</span>
        <span class="mi">125</span><span class="p">:</span> <span class="s">&quot;KEY_LEFTMETA&quot;</span><span class="p">,</span>
        <span class="mi">126</span><span class="p">:</span> <span class="s">&quot;KEY_RIGHTMETA&quot;</span><span class="p">,</span>
        <span class="mi">127</span><span class="p">:</span> <span class="s">&quot;KEY_COMPOSE&quot;</span><span class="p">,</span>
        <span class="mi">128</span><span class="p">:</span> <span class="s">&quot;KEY_STOP&quot;</span><span class="p">,</span>
        <span class="mi">129</span><span class="p">:</span> <span class="s">&quot;KEY_AGAIN&quot;</span><span class="p">,</span>
        <span class="mi">130</span><span class="p">:</span> <span class="s">&quot;KEY_PROPS&quot;</span><span class="p">,</span>
        <span class="mi">131</span><span class="p">:</span> <span class="s">&quot;KEY_UNDO&quot;</span><span class="p">,</span>
        <span class="mi">132</span><span class="p">:</span> <span class="s">&quot;KEY_FRONT&quot;</span><span class="p">,</span>
        <span class="mi">133</span><span class="p">:</span> <span class="s">&quot;KEY_COPY&quot;</span><span class="p">,</span>
        <span class="mi">134</span><span class="p">:</span> <span class="s">&quot;KEY_OPEN&quot;</span><span class="p">,</span>
        <span class="mi">135</span><span class="p">:</span> <span class="s">&quot;KEY_PASTE&quot;</span><span class="p">,</span>
        <span class="mi">136</span><span class="p">:</span> <span class="s">&quot;KEY_FIND&quot;</span><span class="p">,</span>
        <span class="mi">137</span><span class="p">:</span> <span class="s">&quot;KEY_CUT&quot;</span><span class="p">,</span>
        <span class="mi">138</span><span class="p">:</span> <span class="s">&quot;KEY_HELP&quot;</span><span class="p">,</span>
        <span class="mi">139</span><span class="p">:</span> <span class="s">&quot;KEY_MENU&quot;</span><span class="p">,</span>
        <span class="mi">140</span><span class="p">:</span> <span class="s">&quot;KEY_CALC&quot;</span><span class="p">,</span>
        <span class="mi">141</span><span class="p">:</span> <span class="s">&quot;KEY_SETUP&quot;</span><span class="p">,</span>
        <span class="mi">142</span><span class="p">:</span> <span class="s">&quot;KEY_SLEEP&quot;</span><span class="p">,</span>
        <span class="mi">143</span><span class="p">:</span> <span class="s">&quot;KEY_WAKEUP&quot;</span><span class="p">,</span>
        <span class="mi">144</span><span class="p">:</span> <span class="s">&quot;KEY_FILE&quot;</span><span class="p">,</span>
        <span class="mi">145</span><span class="p">:</span> <span class="s">&quot;KEY_SENDFILE&quot;</span><span class="p">,</span>
        <span class="mi">146</span><span class="p">:</span> <span class="s">&quot;KEY_DELETEFILE&quot;</span><span class="p">,</span>
        <span class="mi">147</span><span class="p">:</span> <span class="s">&quot;KEY_XFER&quot;</span><span class="p">,</span>
        <span class="mi">148</span><span class="p">:</span> <span class="s">&quot;KEY_PROG1&quot;</span><span class="p">,</span>
        <span class="mi">149</span><span class="p">:</span> <span class="s">&quot;KEY_PROG2&quot;</span><span class="p">,</span>
        <span class="mi">150</span><span class="p">:</span> <span class="s">&quot;KEY_WWW&quot;</span><span class="p">,</span>
        <span class="mi">151</span><span class="p">:</span> <span class="s">&quot;KEY_MSDOS&quot;</span><span class="p">,</span>
        <span class="mi">152</span><span class="p">:</span> <span class="s">&quot;KEY_COFFEE&quot;</span><span class="p">,</span>
        <span class="mi">153</span><span class="p">:</span> <span class="s">&quot;KEY_DIRECTION&quot;</span><span class="p">,</span>
        <span class="mi">154</span><span class="p">:</span> <span class="s">&quot;KEY_CYCLEWINDOWS&quot;</span><span class="p">,</span>
        <span class="mi">155</span><span class="p">:</span> <span class="s">&quot;KEY_MAIL&quot;</span><span class="p">,</span>
        <span class="mi">156</span><span class="p">:</span> <span class="s">&quot;KEY_BOOKMARKS&quot;</span><span class="p">,</span>
        <span class="mi">157</span><span class="p">:</span> <span class="s">&quot;KEY_COMPUTER&quot;</span><span class="p">,</span>
        <span class="mi">158</span><span class="p">:</span> <span class="s">&quot;KEY_BACK&quot;</span><span class="p">,</span>
        <span class="mi">159</span><span class="p">:</span> <span class="s">&quot;KEY_FORWARD&quot;</span><span class="p">,</span>
        <span class="mi">160</span><span class="p">:</span> <span class="s">&quot;KEY_CLOSECD&quot;</span><span class="p">,</span>
        <span class="mi">161</span><span class="p">:</span> <span class="s">&quot;KEY_EJECTCD&quot;</span><span class="p">,</span>
        <span class="mi">162</span><span class="p">:</span> <span class="s">&quot;KEY_EJECTCLOSECD&quot;</span><span class="p">,</span>
        <span class="mi">163</span><span class="p">:</span> <span class="s">&quot;KEY_NEXTSONG&quot;</span><span class="p">,</span>
        <span class="mi">164</span><span class="p">:</span> <span class="s">&quot;KEY_PLAYPAUSE&quot;</span><span class="p">,</span>
        <span class="mi">165</span><span class="p">:</span> <span class="s">&quot;KEY_PREVIOUSSONG&quot;</span><span class="p">,</span>
        <span class="mi">166</span><span class="p">:</span> <span class="s">&quot;KEY_STOPCD&quot;</span><span class="p">,</span>
        <span class="mi">167</span><span class="p">:</span> <span class="s">&quot;KEY_RECORD&quot;</span><span class="p">,</span>
        <span class="mi">168</span><span class="p">:</span> <span class="s">&quot;KEY_REWIND&quot;</span><span class="p">,</span>
        <span class="mi">169</span><span class="p">:</span> <span class="s">&quot;KEY_PHONE&quot;</span><span class="p">,</span>
        <span class="mi">170</span><span class="p">:</span> <span class="s">&quot;KEY_ISO&quot;</span><span class="p">,</span>
        <span class="mi">171</span><span class="p">:</span> <span class="s">&quot;KEY_CONFIG&quot;</span><span class="p">,</span>
        <span class="mi">172</span><span class="p">:</span> <span class="s">&quot;KEY_HOMEPAGE&quot;</span><span class="p">,</span>
        <span class="mi">173</span><span class="p">:</span> <span class="s">&quot;KEY_REFRESH&quot;</span><span class="p">,</span>
        <span class="mi">174</span><span class="p">:</span> <span class="s">&quot;KEY_EXIT&quot;</span><span class="p">,</span>
        <span class="mi">175</span><span class="p">:</span> <span class="s">&quot;KEY_MOVE&quot;</span><span class="p">,</span>
        <span class="mi">176</span><span class="p">:</span> <span class="s">&quot;KEY_EDIT&quot;</span><span class="p">,</span>
        <span class="mi">177</span><span class="p">:</span> <span class="s">&quot;KEY_SCROLLUP&quot;</span><span class="p">,</span>
        <span class="mi">178</span><span class="p">:</span> <span class="s">&quot;KEY_SCROLLDOWN&quot;</span><span class="p">,</span>
        <span class="mi">179</span><span class="p">:</span> <span class="s">&quot;KEY_KPLEFTPAREN&quot;</span><span class="p">,</span>
        <span class="mi">180</span><span class="p">:</span> <span class="s">&quot;KEY_KPRIGHTPAREN&quot;</span><span class="p">,</span>
        <span class="mi">181</span><span class="p">:</span> <span class="s">&quot;KEY_INTL1&quot;</span><span class="p">,</span>
        <span class="mi">182</span><span class="p">:</span> <span class="s">&quot;KEY_INTL2&quot;</span><span class="p">,</span>
        <span class="mi">183</span><span class="p">:</span> <span class="s">&quot;KEY_INTL3&quot;</span><span class="p">,</span>
        <span class="mi">184</span><span class="p">:</span> <span class="s">&quot;KEY_INTL4&quot;</span><span class="p">,</span>
        <span class="mi">185</span><span class="p">:</span> <span class="s">&quot;KEY_INTL5&quot;</span><span class="p">,</span>
        <span class="mi">186</span><span class="p">:</span> <span class="s">&quot;KEY_INTL6&quot;</span><span class="p">,</span>
        <span class="mi">187</span><span class="p">:</span> <span class="s">&quot;KEY_INTL7&quot;</span><span class="p">,</span>
        <span class="mi">188</span><span class="p">:</span> <span class="s">&quot;KEY_INTL8&quot;</span><span class="p">,</span>
        <span class="mi">189</span><span class="p">:</span> <span class="s">&quot;KEY_INTL9&quot;</span><span class="p">,</span>
        <span class="mi">190</span><span class="p">:</span> <span class="s">&quot;KEY_LANG1&quot;</span><span class="p">,</span>
        <span class="mi">191</span><span class="p">:</span> <span class="s">&quot;KEY_LANG2&quot;</span><span class="p">,</span>
        <span class="mi">192</span><span class="p">:</span> <span class="s">&quot;KEY_LANG3&quot;</span><span class="p">,</span>
        <span class="mi">193</span><span class="p">:</span> <span class="s">&quot;KEY_LANG4&quot;</span><span class="p">,</span>
        <span class="mi">194</span><span class="p">:</span> <span class="s">&quot;KEY_LANG5&quot;</span><span class="p">,</span>
        <span class="mi">195</span><span class="p">:</span> <span class="s">&quot;KEY_LANG6&quot;</span><span class="p">,</span>
        <span class="mi">196</span><span class="p">:</span> <span class="s">&quot;KEY_LANG7&quot;</span><span class="p">,</span>
        <span class="mi">197</span><span class="p">:</span> <span class="s">&quot;KEY_LANG8&quot;</span><span class="p">,</span>
        <span class="mi">198</span><span class="p">:</span> <span class="s">&quot;KEY_LANG9&quot;</span><span class="p">,</span>
        <span class="mi">200</span><span class="p">:</span> <span class="s">&quot;KEY_PLAYCD&quot;</span><span class="p">,</span>
        <span class="mi">201</span><span class="p">:</span> <span class="s">&quot;KEY_PAUSECD&quot;</span><span class="p">,</span>
        <span class="mi">202</span><span class="p">:</span> <span class="s">&quot;KEY_PROG3&quot;</span><span class="p">,</span>
        <span class="mi">203</span><span class="p">:</span> <span class="s">&quot;KEY_PROG4&quot;</span><span class="p">,</span>
        <span class="mi">205</span><span class="p">:</span> <span class="s">&quot;KEY_SUSPEND&quot;</span><span class="p">,</span>
        <span class="mi">206</span><span class="p">:</span> <span class="s">&quot;KEY_CLOSE&quot;</span><span class="p">,</span>
        <span class="mi">220</span><span class="p">:</span> <span class="s">&quot;KEY_UNKNOWN&quot;</span><span class="p">,</span>
        <span class="mi">224</span><span class="p">:</span> <span class="s">&quot;KEY_BRIGHTNESSDOWN&quot;</span><span class="p">,</span>
        <span class="mi">225</span><span class="p">:</span> <span class="s">&quot;KEY_BRIGHTNESSUP&quot;</span><span class="p">,</span>
        <span class="mh">0x100</span><span class="p">:</span> <span class="s">&quot;BTN_0&quot;</span><span class="p">,</span>
        <span class="mh">0x101</span><span class="p">:</span> <span class="s">&quot;BTN_1&quot;</span><span class="p">,</span>
        <span class="mh">0x102</span><span class="p">:</span> <span class="s">&quot;BTN_2&quot;</span><span class="p">,</span>
        <span class="mh">0x103</span><span class="p">:</span> <span class="s">&quot;BTN_3&quot;</span><span class="p">,</span>
        <span class="mh">0x104</span><span class="p">:</span> <span class="s">&quot;BTN_4&quot;</span><span class="p">,</span>
        <span class="mh">0x105</span><span class="p">:</span> <span class="s">&quot;BTN_5&quot;</span><span class="p">,</span>
        <span class="mh">0x106</span><span class="p">:</span> <span class="s">&quot;BTN_6&quot;</span><span class="p">,</span>
        <span class="mh">0x107</span><span class="p">:</span> <span class="s">&quot;BTN_7&quot;</span><span class="p">,</span>
        <span class="mh">0x108</span><span class="p">:</span> <span class="s">&quot;BTN_8&quot;</span><span class="p">,</span>
        <span class="mh">0x109</span><span class="p">:</span> <span class="s">&quot;BTN_9&quot;</span><span class="p">,</span>
        <span class="mh">0x110</span><span class="p">:</span> <span class="s">&quot;BTN_LEFT&quot;</span><span class="p">,</span>
        <span class="mh">0x111</span><span class="p">:</span> <span class="s">&quot;BTN_RIGHT&quot;</span><span class="p">,</span>
        <span class="mh">0x112</span><span class="p">:</span> <span class="s">&quot;BTN_MIDDLE&quot;</span><span class="p">,</span>
        <span class="mh">0x113</span><span class="p">:</span> <span class="s">&quot;BTN_SIDE&quot;</span><span class="p">,</span>
        <span class="mh">0x114</span><span class="p">:</span> <span class="s">&quot;BTN_EXTRA&quot;</span><span class="p">,</span>
        <span class="mh">0x115</span><span class="p">:</span> <span class="s">&quot;BTN_FORWARD&quot;</span><span class="p">,</span>
        <span class="mh">0x116</span><span class="p">:</span> <span class="s">&quot;BTN_BACK&quot;</span><span class="p">,</span>
        <span class="mh">0x120</span><span class="p">:</span> <span class="s">&quot;BTN_TRIGGER&quot;</span><span class="p">,</span>
        <span class="mh">0x121</span><span class="p">:</span> <span class="s">&quot;BTN_THUMB&quot;</span><span class="p">,</span>
        <span class="mh">0x122</span><span class="p">:</span> <span class="s">&quot;BTN_THUMB2&quot;</span><span class="p">,</span>
        <span class="mh">0x123</span><span class="p">:</span> <span class="s">&quot;BTN_TOP&quot;</span><span class="p">,</span>
        <span class="mh">0x124</span><span class="p">:</span> <span class="s">&quot;BTN_TOP2&quot;</span><span class="p">,</span>
        <span class="mh">0x125</span><span class="p">:</span> <span class="s">&quot;BTN_PINKIE&quot;</span><span class="p">,</span>
        <span class="mh">0x126</span><span class="p">:</span> <span class="s">&quot;BTN_BASE&quot;</span><span class="p">,</span>
        <span class="mh">0x127</span><span class="p">:</span> <span class="s">&quot;BTN_BASE2&quot;</span><span class="p">,</span>
        <span class="mh">0x128</span><span class="p">:</span> <span class="s">&quot;BTN_BASE3&quot;</span><span class="p">,</span>
        <span class="mh">0x129</span><span class="p">:</span> <span class="s">&quot;BTN_BASE4&quot;</span><span class="p">,</span>
        <span class="mh">0x12a</span><span class="p">:</span> <span class="s">&quot;BTN_BASE5&quot;</span><span class="p">,</span>
        <span class="mh">0x12b</span><span class="p">:</span> <span class="s">&quot;BTN_BASE6&quot;</span><span class="p">,</span>
        <span class="mh">0x12f</span><span class="p">:</span> <span class="s">&quot;BTN_DEAD&quot;</span><span class="p">,</span>
        <span class="mh">0x130</span><span class="p">:</span> <span class="s">&quot;BTN_A&quot;</span><span class="p">,</span>
        <span class="mh">0x131</span><span class="p">:</span> <span class="s">&quot;BTN_B&quot;</span><span class="p">,</span>
        <span class="mh">0x132</span><span class="p">:</span> <span class="s">&quot;BTN_C&quot;</span><span class="p">,</span>
        <span class="mh">0x133</span><span class="p">:</span> <span class="s">&quot;BTN_X&quot;</span><span class="p">,</span>
        <span class="mh">0x134</span><span class="p">:</span> <span class="s">&quot;BTN_Y&quot;</span><span class="p">,</span>
        <span class="mh">0x135</span><span class="p">:</span> <span class="s">&quot;BTN_Z&quot;</span><span class="p">,</span>
        <span class="mh">0x136</span><span class="p">:</span> <span class="s">&quot;BTN_TL&quot;</span><span class="p">,</span>
        <span class="mh">0x137</span><span class="p">:</span> <span class="s">&quot;BTN_TR&quot;</span><span class="p">,</span>
        <span class="mh">0x138</span><span class="p">:</span> <span class="s">&quot;BTN_TL2&quot;</span><span class="p">,</span>
        <span class="mh">0x139</span><span class="p">:</span> <span class="s">&quot;BTN_TR2&quot;</span><span class="p">,</span>
        <span class="mh">0x13a</span><span class="p">:</span> <span class="s">&quot;BTN_SELECT&quot;</span><span class="p">,</span>
        <span class="mh">0x13b</span><span class="p">:</span> <span class="s">&quot;BTN_START&quot;</span><span class="p">,</span>
        <span class="mh">0x13c</span><span class="p">:</span> <span class="s">&quot;BTN_MODE&quot;</span><span class="p">,</span>
        <span class="mh">0x13d</span><span class="p">:</span> <span class="s">&quot;BTN_THUMBL&quot;</span><span class="p">,</span>
        <span class="mh">0x13e</span><span class="p">:</span> <span class="s">&quot;BTN_THUMBR&quot;</span><span class="p">,</span>
        <span class="mh">0x140</span><span class="p">:</span> <span class="s">&quot;BTN_TOOL_PEN&quot;</span><span class="p">,</span>
        <span class="mh">0x141</span><span class="p">:</span> <span class="s">&quot;BTN_TOOL_RUBBER&quot;</span><span class="p">,</span>
        <span class="mh">0x142</span><span class="p">:</span> <span class="s">&quot;BTN_TOOL_BRUSH&quot;</span><span class="p">,</span>
        <span class="mh">0x143</span><span class="p">:</span> <span class="s">&quot;BTN_TOOL_PENCIL&quot;</span><span class="p">,</span>
        <span class="mh">0x144</span><span class="p">:</span> <span class="s">&quot;BTN_TOOL_AIRBRUSH&quot;</span><span class="p">,</span>
        <span class="mh">0x145</span><span class="p">:</span> <span class="s">&quot;BTN_TOOL_FINGER&quot;</span><span class="p">,</span>
        <span class="mh">0x146</span><span class="p">:</span> <span class="s">&quot;BTN_TOOL_MOUSE&quot;</span><span class="p">,</span>
        <span class="mh">0x147</span><span class="p">:</span> <span class="s">&quot;BTN_TOOL_LENS&quot;</span><span class="p">,</span>
        <span class="mh">0x14a</span><span class="p">:</span> <span class="s">&quot;BTN_TOUCH&quot;</span><span class="p">,</span>
        <span class="mh">0x14b</span><span class="p">:</span> <span class="s">&quot;BTN_STYLUS&quot;</span><span class="p">,</span>
        <span class="mh">0x14c</span><span class="p">:</span> <span class="s">&quot;BTN_STYLUS2&quot;</span><span class="p">,</span>
        <span class="p">}),</span>

        <span class="s">&quot;EV_REL&quot;</span><span class="p">:</span> <span class="n">EnumDict</span><span class="p">({</span>
        <span class="mh">0x00</span><span class="p">:</span> <span class="s">&quot;REL_X&quot;</span><span class="p">,</span>
        <span class="mh">0x01</span><span class="p">:</span> <span class="s">&quot;REL_Y&quot;</span><span class="p">,</span>
        <span class="mh">0x02</span><span class="p">:</span> <span class="s">&quot;REL_Z&quot;</span><span class="p">,</span>
        <span class="mh">0x06</span><span class="p">:</span> <span class="s">&quot;REL_HWHEEL&quot;</span><span class="p">,</span>
        <span class="mh">0x07</span><span class="p">:</span> <span class="s">&quot;REL_DIAL&quot;</span><span class="p">,</span>
        <span class="mh">0x08</span><span class="p">:</span> <span class="s">&quot;REL_WHEEL&quot;</span><span class="p">,</span>
        <span class="mh">0x09</span><span class="p">:</span> <span class="s">&quot;REL_MISC&quot;</span><span class="p">,</span>
        <span class="p">}),</span>

        <span class="s">&quot;EV_ABS&quot;</span><span class="p">:</span> <span class="n">EnumDict</span><span class="p">({</span>
        <span class="mh">0x00</span><span class="p">:</span> <span class="s">&quot;ABS_X&quot;</span><span class="p">,</span>
        <span class="mh">0x01</span><span class="p">:</span> <span class="s">&quot;ABS_Y&quot;</span><span class="p">,</span>
        <span class="mh">0x02</span><span class="p">:</span> <span class="s">&quot;ABS_Z&quot;</span><span class="p">,</span>
        <span class="mh">0x03</span><span class="p">:</span> <span class="s">&quot;ABS_RX&quot;</span><span class="p">,</span>
        <span class="mh">0x04</span><span class="p">:</span> <span class="s">&quot;ABS_RY&quot;</span><span class="p">,</span>
        <span class="mh">0x05</span><span class="p">:</span> <span class="s">&quot;ABS_RZ&quot;</span><span class="p">,</span>
        <span class="mh">0x06</span><span class="p">:</span> <span class="s">&quot;ABS_THROTTLE&quot;</span><span class="p">,</span>
        <span class="mh">0x07</span><span class="p">:</span> <span class="s">&quot;ABS_RUDDER&quot;</span><span class="p">,</span>
        <span class="mh">0x08</span><span class="p">:</span> <span class="s">&quot;ABS_WHEEL&quot;</span><span class="p">,</span>
        <span class="mh">0x09</span><span class="p">:</span> <span class="s">&quot;ABS_GAS&quot;</span><span class="p">,</span>
        <span class="mh">0x0a</span><span class="p">:</span> <span class="s">&quot;ABS_BRAKE&quot;</span><span class="p">,</span>
        <span class="mh">0x10</span><span class="p">:</span> <span class="s">&quot;ABS_HAT0X&quot;</span><span class="p">,</span>
        <span class="mh">0x11</span><span class="p">:</span> <span class="s">&quot;ABS_HAT0Y&quot;</span><span class="p">,</span>
        <span class="mh">0x12</span><span class="p">:</span> <span class="s">&quot;ABS_HAT1X&quot;</span><span class="p">,</span>
        <span class="mh">0x13</span><span class="p">:</span> <span class="s">&quot;ABS_HAT1Y&quot;</span><span class="p">,</span>
        <span class="mh">0x14</span><span class="p">:</span> <span class="s">&quot;ABS_HAT2X&quot;</span><span class="p">,</span>
        <span class="mh">0x15</span><span class="p">:</span> <span class="s">&quot;ABS_HAT2Y&quot;</span><span class="p">,</span>
        <span class="mh">0x16</span><span class="p">:</span> <span class="s">&quot;ABS_HAT3X&quot;</span><span class="p">,</span>
        <span class="mh">0x17</span><span class="p">:</span> <span class="s">&quot;ABS_HAT3Y&quot;</span><span class="p">,</span>
        <span class="mh">0x18</span><span class="p">:</span> <span class="s">&quot;ABS_PRESSURE&quot;</span><span class="p">,</span>
        <span class="mh">0x19</span><span class="p">:</span> <span class="s">&quot;ABS_DISTANCE&quot;</span><span class="p">,</span>
        <span class="mh">0x1a</span><span class="p">:</span> <span class="s">&quot;ABS_TILT_X&quot;</span><span class="p">,</span>
        <span class="mh">0x1b</span><span class="p">:</span> <span class="s">&quot;ABS_TILT_Y&quot;</span><span class="p">,</span>
        <span class="mh">0x1c</span><span class="p">:</span> <span class="s">&quot;ABS_MISC&quot;</span><span class="p">,</span>
        <span class="p">}),</span>

        <span class="s">&quot;EV_MSC&quot;</span><span class="p">:</span> <span class="n">EnumDict</span><span class="p">({</span>
        <span class="mh">0x00</span><span class="p">:</span> <span class="s">&quot;MSC_SERIAL&quot;</span><span class="p">,</span>
        <span class="mh">0x01</span><span class="p">:</span> <span class="s">&quot;MSC_PULSELED&quot;</span><span class="p">,</span>
        <span class="p">}),</span>

        <span class="s">&quot;EV_LED&quot;</span><span class="p">:</span> <span class="n">EnumDict</span><span class="p">({</span>
        <span class="mh">0x00</span><span class="p">:</span> <span class="s">&quot;LED_NUML&quot;</span><span class="p">,</span>
        <span class="mh">0x01</span><span class="p">:</span> <span class="s">&quot;LED_CAPSL&quot;</span><span class="p">,</span>
        <span class="mh">0x02</span><span class="p">:</span> <span class="s">&quot;LED_SCROLLL&quot;</span><span class="p">,</span>
        <span class="mh">0x03</span><span class="p">:</span> <span class="s">&quot;LED_COMPOSE&quot;</span><span class="p">,</span>
        <span class="mh">0x04</span><span class="p">:</span> <span class="s">&quot;LED_KANA&quot;</span><span class="p">,</span>
        <span class="mh">0x05</span><span class="p">:</span> <span class="s">&quot;LED_SLEEP&quot;</span><span class="p">,</span>
        <span class="mh">0x06</span><span class="p">:</span> <span class="s">&quot;LED_SUSPEND&quot;</span><span class="p">,</span>
        <span class="mh">0x07</span><span class="p">:</span> <span class="s">&quot;LED_MUTE&quot;</span><span class="p">,</span>
        <span class="mh">0x08</span><span class="p">:</span> <span class="s">&quot;LED_MISC&quot;</span><span class="p">,</span>
        <span class="p">}),</span>

        <span class="s">&quot;EV_REP&quot;</span><span class="p">:</span> <span class="n">EnumDict</span><span class="p">({</span>
        <span class="mh">0x00</span><span class="p">:</span> <span class="s">&quot;REP_DELAY&quot;</span><span class="p">,</span>
        <span class="mh">0x01</span><span class="p">:</span> <span class="s">&quot;REP_PERIOD&quot;</span><span class="p">,</span>
        <span class="p">}),</span>

        <span class="s">&quot;EV_SND&quot;</span><span class="p">:</span> <span class="n">EnumDict</span><span class="p">({</span>
        <span class="mh">0x00</span><span class="p">:</span> <span class="s">&quot;SND_CLICK&quot;</span><span class="p">,</span>
        <span class="mh">0x01</span><span class="p">:</span> <span class="s">&quot;SND_BELL&quot;</span><span class="p">,</span>
        <span class="p">}),</span>
        <span class="p">}</span>

    <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">timestamp</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">code</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">value</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">unpack</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">readFrom</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">timestamp</span> <span class="o">=</span> <span class="n">timestamp</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="nb">type</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">code</span> <span class="o">=</span> <span class="n">code</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">value</span>
        <span class="k">if</span> <span class="n">unpack</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="n">unpack</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">readFrom</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">readFrom</span><span class="p">(</span><span class="n">readFrom</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="k">return</span> <span class="s">&quot;&lt;Event timestamp=</span><span class="si">%r</span><span class="s"> type=</span><span class="si">%r</span><span class="s"> code=</span><span class="si">%r</span><span class="s"> value=</span><span class="si">%r</span><span class="s">&gt;&quot;</span> <span class="o">%</span> <span class="p">(</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">timestamp</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">code</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
    
    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">get_format_size</span><span class="p">():</span>
        <span class="k">return</span> <span class="n">struct</span><span class="o">.</span><span class="n">calcsize</span><span class="p">(</span><span class="n">Event</span><span class="o">.</span><span class="n">ts_format</span><span class="p">)</span> <span class="o">+</span> <span class="n">struct</span><span class="o">.</span><span class="n">calcsize</span><span class="p">(</span><span class="n">Event</span><span class="o">.</span><span class="n">format</span><span class="p">)</span>
    
<div class="viewcode-block" id="Event.pack"><a class="viewcode-back" href="../../../../ui.html#pyamp.ui.input.evdev.Event.pack">[docs]</a>    <span class="k">def</span> <span class="nf">pack</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Pack this event into an input_event struct in</span>
<span class="sd">           the local machine&#39;s byte order.</span>
<span class="sd">           &quot;&quot;&quot;</span>
        <span class="n">secs</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">timestamp</span><span class="p">)</span>
        <span class="n">usecs</span> <span class="o">=</span> <span class="nb">int</span><span class="p">((</span><span class="bp">self</span><span class="o">.</span><span class="n">timestamp</span> <span class="o">-</span> <span class="n">secs</span><span class="p">)</span> <span class="o">*</span> <span class="mi">1000000</span><span class="p">)</span>
        <span class="n">packedType</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">typeMap</span><span class="o">.</span><span class="n">toNumber</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">codeMaps</span><span class="p">:</span>
            <span class="n">packedCode</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">codeMaps</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">]</span><span class="o">.</span><span class="n">toNumber</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">code</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">packedCode</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">code</span>
        <span class="k">return</span> <span class="n">struct</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ts_format</span><span class="p">,</span> <span class="n">secs</span><span class="p">,</span> <span class="n">usecs</span><span class="p">)</span> <span class="o">+</span> \
               <span class="n">struct</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">format</span><span class="p">,</span> <span class="n">packedType</span><span class="p">,</span> <span class="n">packedCode</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">value</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Event.unpack"><a class="viewcode-back" href="../../../../ui.html#pyamp.ui.input.evdev.Event.unpack">[docs]</a>    <span class="k">def</span> <span class="nf">unpack</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">s</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Unpack ourselves from the given string,, an</span>
<span class="sd">           input_event struct in the local byte order.</span>
<span class="sd">           &quot;&quot;&quot;</span>
        <span class="n">ts_len</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">calcsize</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ts_format</span><span class="p">)</span>
        <span class="n">secs</span><span class="p">,</span> <span class="n">usecs</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">ts_format</span><span class="p">,</span> <span class="n">s</span><span class="p">[:</span><span class="n">ts_len</span><span class="p">])</span>
        <span class="n">packedType</span><span class="p">,</span> <span class="n">packedCode</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">value</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">format</span><span class="p">,</span> <span class="n">s</span><span class="p">[</span><span class="n">ts_len</span><span class="p">:])</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">timestamp</span> <span class="o">=</span> <span class="n">secs</span> <span class="o">+</span> <span class="p">(</span><span class="n">usecs</span> <span class="o">/</span> <span class="mf">1000000.0</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">typeMap</span><span class="o">.</span><span class="n">fromNumber</span><span class="p">(</span><span class="n">packedType</span><span class="p">)</span>
        <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">type</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">codeMaps</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">code</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">codeMaps</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">type</span><span class="p">]</span><span class="o">.</span><span class="n">fromNumber</span><span class="p">(</span><span class="n">packedCode</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">code</span> <span class="o">=</span> <span class="n">packedCode</span>
</div>
<div class="viewcode-block" id="Event.readFrom"><a class="viewcode-back" href="../../../../ui.html#pyamp.ui.input.evdev.Event.readFrom">[docs]</a>    <span class="k">def</span> <span class="nf">readFrom</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">stream</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;Read the next event from the given file-like object&quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="n">stream</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">Event</span><span class="o">.</span><span class="n">get_format_size</span><span class="p">()))</span>

</div></div>
<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&quot;__main__&quot;</span><span class="p">:</span>
    <span class="n">demo</span><span class="p">()</span>

<span class="c">### The End ###</span>
</pre></div>

          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../../../search.html" method="get">
      <input type="text" name="q" size="18" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../../../index.html">pyamp v1.2 documentation</a> &raquo;</li>
          <li><a href="../../../index.html" >Module code</a> &raquo;</li>
          <li><a href="../input.html" >pyamp.ui.input</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Brett Ponsler.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.1.
    </div>
  </body>
</html>